// 编辑器的初始化参数
var small_ckeditor_toolbar=[
    ["Source","PasteText","Autoformat","Bold","Italic","Underline"],//加粗,斜体,自动排版,下划线,穿过线,下标字,上标字
    ["JustifyLeft","JustifyCenter","JustifyRight"],//左对齐,居中对齐,右对齐,两端对齐
    ["Link","Unlink"],//超链接,取消超链接,锚点
    ["Font","FontSize"],//样式,格式,字体,字体大小
    ["TextColor"],//文本颜色,背景颜色
    
    ["upimg","Table"],//"Image","Flash",图片,flash,表格,水平线,特殊字符,
    ["Maximize"]
];
//催促审批
function audit_alert(utype){
    $.post('/app/user/home.php?m=audit_alert', {utype:utype}, function(data) {
        try{
            var ret=$.evalJSON(data);
            C.alert.alert({content:ret.msg});
        }catch(e){alert(e.message+data);}
    });
}
$(function(){
    $('.user_menu ul').css({height:$('.main').height()+10});
    
    $('.topmenu_txt').hover(function(){
        $(this).find('.topmenu_con').stop().show();
    },function(){
        $(this).find('.topmenu_con').stop().hide();
    });
    
    
    $('.lmenu>.but1').click(function(){
        if($(this).parent().find('.txt3').css('display')=='block'){
            $(this).parent().find('.txt3').css('display','none');
        }else{
            $(this).parent().find('.txt3').css('display','block');
        }
    });
    
    $('.bot_m').click(function(){
        $('.foot_hidden').css('display','none');
        if($('.bot_service').css('display')=='none'){
            $('.bot_service').show();
        }else{
            $('.bot_service').hide();
        }
    });
    $('.bot_u').click(function(){
        $('.foot_hidden').css('display','none');
        if($('.bot_user').css('display')=='none'){
            $('.bot_user').show();
        }else{
            $('.bot_user').hide();
        }
    });
    
    $('.tbut').hover(function(){
        $(this).find('.tbut_menu').css('display','block');
    },function(){
        $(this).find('.tbut_menu').css('display','none');
    });
    
    $('#tsearch_select').hover(function(){
        $('#tsearch_select_div').stop().show();
    },function(){
        $('#tsearch_select_div').stop().hide();
    });
    $('#tsearch_select_div>a').click(function(){
        $('#tsearch_select_div').stop().hide();
    });
    
    $('.uright').find('.table1').find('tr').click(function(){
        var chkbox=$(this).find('.chklist');
        if(chkbox.length==1){
            if(chkbox.attr('checked')){
                chkbox.attr('checked',false);
            }else{
                chkbox.attr('checked',true);
            }
        }
        $('.chklist').each(function(){
            if($(this).attr('checked')){
                $(this).parent().parent().css({'background':'#f1f1f1'});
            }else{
                $(this).parent().parent().css({'background':'none'});
            }
        });
    });
    $('.chklist').click(function(e){
       e.stopPropagation();
       $('.chklist').each(function(){
            if($(this).attr('checked')){
                $(this).parent().parent().css({'background':'#f1f1f1'});
            }else{
                $(this).parent().parent().css({'background':'none'});
            }
        });
    });
    $('.table1').find('a').click(function(e){
        e.stopPropagation();
    });
    
});
function top_search(){
    var stype=$('#stype').val();
    var sq=$('#sq').val();
    if(sq.length<2){
        C.alert.alert({content:'请输入搜索关键词',funcOk:function(){$('#sq').focus();}});return;
    }
    sq=encodeURIComponent(sq);
    switch(stype){
        case '1':
            window.location.href="/app/opp/list.php?state=&name="+sq;
            break;
        case '2':
            window.location.href="/app/org/list.php?name="+sq;
            break;
        case '3':
            window.location.href="/index.php?tpl=search&q="+sq;
            break;
        default:
            C.alert.alert({content:'搜索类型错误'});
    }
}
function chpos(o){
    var self=$(o)[0].outerHTML; 
    $(o).parent().prepend(self);
    $(o).remove();
}
function address_blur(id){
    $('#'+id).trigger('blur');
}
//发布求助
function sub_gbook(){
    $('.v_result').html('');
    var marea='#gbook';
    var postdata=C.form.get_form(marea);
    $.post('/app/help/gbook.php?m=save_gbook', postdata, function(data) {
        try {
            var ret = $.evalJSON(data);
            if(ret.code=='1'){
                C.alert.show(ret.msg);
            }else{
                C.alert.show(ret.msg);
                $('#gbook').find('#type').val('');
                $('#gbook').find('#true_name').val('');
                $('#gbook').find('#content').val('');
            }
        } catch (e) {
            C.alert.show('error:'+data);
        }
    });
}
//显示图形验证码层，获取手机验证码
function show_sms_div(mobile){
    if(!arguments[0]) var mobile='login_mobile';
    var mobile=$('#'+mobile).val();
    if(mobile==''){
        C.alert.show('手机号码不能为空');
        $('#'+mobile).focus();
        return;
    }
    
    C.alert.opacty({title:'获取手机验证码',width:230,height:80,'div_tag':'#sms_div'});
    $('#sms_div').find('#check_mobile').val(mobile);
}
function check_sms_code(type){
    //alert(type);
    var vcode_sms=$('#vcode_sms').val();
    if(vcode_sms=='') {
        C.alert.show('图形验证码不能为空');
        $('#vcode_sms').focus();
        return;
    }
    var login_mobile=$('#sms_div').find('#check_mobile').val();
    
    $.post('/app/api/view.php?m=check_sms_code&type='+type+'&vcode_sms='+vcode_sms+'&mobile='+login_mobile, {}, function(data) {
        try {
            var ret = $.evalJSON(data);
            C.alert.show(ret.msg);
            $('#vcode_reg_vol_sms').click();
            if(ret.code=='0') C.alert.opacty_close('#sms_div');
            
        } catch (e) {
            C.alert.show('error:'+data);
        }
    });
}

function get_tree_select(type,parent_id,level){
    $.post('/app/api/view.php?m=get_tree_select&type='+type+'&parent_id='+parent_id+'&level='+level, {}, function(data) {
        try {
            //alert(data);
            $('#'+type+level).parent().html(data);
            $('#'+type+(1+level)).html('<option value="">请选择</option>');
            $('#'+type+(2+level)).html('<option value="">请选择</option>');
        } catch (e) {
            C.alert.show('error:'+data);
        }
    });
}
